package com.starblink.utils.network.ext

object ApolloValSetExt {


    //反射修改apollo的值
    inline fun <reified T> setApolloVal(
        model: Any,
        declaredField: String,
        value: Any?
    ) {
        try {
            val modelField = T::class.java.getDeclaredField(declaredField)
            modelField.isAccessible = true
            modelField.set(model, value)
        } catch (e: Throwable) {
            e.printStackTrace()
        }
    }

    inline fun <reified T: Any> T.apolloValue(fieldName: String, value: Any?) {
        setApolloVal<T>(this, fieldName, value)
    }

}